package com.wicket.okrapp.base.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wicket.okrapp.base.service.MSpaceService;
import com.wicket.okrapp.common.exception.BizException;
import com.wicket.okrapp.common.util.CommonFunctionHelper;
import com.wicket.okrapp.dal.mapper.mbg.SpaceMapper;
import com.wicket.okrapp.dal.po.mbg.Space;
import com.wicket.okrapp.base.service.dto.req.*;
//import com.wicket.okrapp.base.service.dto.res.*;

import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;

import java.util.*;
import java.util.ArrayList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author ：
 * @since 2022/1/19 15:39
 *
 * 
 * @version 1.0
 */
@Service
public class MSpaceServiceImpl
  extends ServiceImpl<SpaceMapper, Space>
  implements MSpaceService {

  @Autowired
  SpaceMapper spaceMapper;
/**
   * M3执行长生调度空间【循环开始】[5094]
   * gen by moon at 11/2/2022, 7:42:54 AM
   */
 @Trace(operationName = "M3执行长生调度空间【循环开始】")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  Space  implementEverYoungDispatchSpaceLoopStart(ImplementEverYoungDispatchSpaceLoopStartReq reqDto) {
     
        try {
         
            QueryWrapper<Space> queryWrapper = new QueryWrapper<>();
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, new ArrayList<>());
            queryWrapper.orderByDesc("create_time");
            if(super.list(queryWrapper)!=null && super.list(queryWrapper).size()>0){
                Space retData = super.list(queryWrapper).get(0);
                
                return retData;
            }
            return null;
      } catch (Exception e) {
          e.printStackTrace();
          throw new BizException("-1",e,false);
      }
  }

}

